#!/bin/bash
echo "========1. Dropping previous database..."
/usr/lib/postgresql/8.3/bin/dropdb -h $GROUP3705HOST -p 5132 tpch
echo "========2. Creating new database..."
/usr/lib/postgresql/8.3/bin/createdb -h $GROUP3705HOST -p 5132 tpch
echo "========3. Importing table structure..."
/usr/lib/postgresql/8.3/bin/psql -h $GROUP3705HOST -p 5132 tpch < $HOME/dbgen/dss.ddl
echo "========4. Creating the user and granting..."
/usr/lib/postgresql/8.3/bin/psql -h $GROUP3705HOST -p 5132 tpch < $HOME/server/create_grant.sql
echo "========5. Generating the database..."
cd $HOME/dbgen
./dbgen -f -v -s 0.1
echo "========6. Removing trailing | chars..."
$HOME/server/remove_trailing.sh
echo "========7. Importing generated database..."
/usr/lib/postgresql/8.3/bin/psql -h $GROUP3705HOST -p 5132 tpch < $HOME/server/table_copy.sql
